package mvc.viviani;

import java.awt.Dimension;
import java.awt.GridBagConstraints;

import org.geom.render.Engine2D;

import mvc.ControllerMouse3D;
import mvc.CurveView3D;
import mvc.MouseController2D;
import mvc.ViewCurve2D;
import gui.Block;

public class VivianiBlock extends Block {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	
	VivianiModel curve;
	
	public VivianiBlock(String title, VivianiModel model) {
		super(title);
		this.curve = model;
		
		initSwing(model);
	}

	private void initSwing(VivianiModel viviani) {
		ViewCurve2D view2d;
		CurveView3D view3d;
		MouseController2D controller2d;
		ControllerMouse3D controller3d;
		
		Dimension dim = new Dimension(380,300);
		
		GridBagConstraints c = new GridBagConstraints();
		c.gridx = 0;
		c.gridy = 0;
		c.weightx = 10;
		c.weighty = 10;
		view2d = new ViewCurve2D(viviani, Engine2D.X, dim);
		viviani.addView(view2d);
		controller2d = new MouseController2D(viviani, Engine2D.X, view2d);
		view2d.addMouseController(controller2d);
		//view2d.setTranslate(new Point3D(50, 100, 0));
		addView(view2d, c);
		
		c = new GridBagConstraints();
		c.gridx = 0;
		c.gridy = 1;
		c.weightx = 10;
		c.weighty = 10;
		view2d = new ViewCurve2D(viviani, Engine2D.Y, dim);
		controller2d = new MouseController2D(viviani, Engine2D.Y, view2d);
		viviani.addView(view2d);
		view2d.addMouseController(controller2d);
		//view2d.setTranslate(new Point3D(50, 100, 0));
		addView(view2d, c);

		c = new GridBagConstraints();
		c.gridx = 1;
		c.gridy = 0;
		c.weightx = 10;
		c.weighty = 10;
		view2d = new ViewCurve2D(viviani, Engine2D.Z, dim);
		controller2d = new MouseController2D(viviani, Engine2D.Z, view2d);
		viviani.addView(view2d);
		view2d.addMouseController(controller2d);
		//view2d.setTranslate(new Point3D(50, 100, 0));
		addView(view2d, c);

		c = new GridBagConstraints();
		c.gridx = 1;
		c.gridy = 1;
		c.weightx = 10;
		c.weighty = 10;
		view3d = new CurveView3D(viviani, dim);
		viviani.addView(view3d);
		controller3d = new ControllerMouse3D(view3d);
		view3d.addMouseKeybController(controller3d);
		addView(view3d, c);
	}
	
	@Override
	protected void initControls() {
		super.initControls();
	}

}
